import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '用户',
    align: "center",
    dataIndex: 'userId_dictText'
  },
  {
    title: '订单号',
    align: "center",
    dataIndex: 'orderId'
  },
  {
    title: '支付状态',
    align: "center",
    dataIndex: 'paymentStatus_dictText'
  },
  {
    title: '支付金额',
    align: "center",
    dataIndex: 'paymentAmount'
  },
  {
    title: '退款时间',
    align: "center",
    dataIndex: 'refundTime'
  },
  {
    title: '支付方式',
    align: "center",
    dataIndex: 'paymentMethod_dictText'
  },
  {
    title: '支付订单号',
    align: "center",
    dataIndex: 'paymentReference'
  },
  {
    title: '备注信息',
    align: "center",
    dataIndex: 'note'
  },
  {
    title: '支付时间',
    align: "center",
    dataIndex: 'paymentTime'
  },
  {
    title: '实付金额',
    align: "center",
    dataIndex: 'paidAmount'
  },
  {
    title: '商品ID',
    align: "center",
    dataIndex: 'productId'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "用户",
    field: 'userId',
    component: 'JSearchSelect',
    componentProps: {
      dict: "cu_user_details,user_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "订单号",
    field: 'orderId',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "支付状态",
    field: 'paymentStatus',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "payment_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "退款时间",
    field: 'refundTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    //colProps: {span: 6},
  },
  {
    label: "支付方式",
    field: 'paymentMethod',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "payment_method"
    },
    //colProps: {span: 6},
  },
  {
    label: "支付订单号",
    field: 'paymentReference',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "支付时间",
    field: 'paymentTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '用户',
    field: 'userId',
    component: 'JSearchSelect',
    componentProps: {
      dict: "cu_user_details,user_name,id"
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入用户!' },
      ];
    },
  },
  {
    label: '订单号',
    field: 'orderId',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入订单号!' },
      ];
    },
  },
  {
    label: '支付状态',
    field: 'paymentStatus',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "payment_status"
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入支付状态!' },
      ];
    },
  },
  {
    label: '支付金额',
    field: 'paymentAmount',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入支付金额!' },
      ];
    },
  },
  {
    label: '退款时间',
    field: 'refundTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '支付方式',
    field: 'paymentMethod',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "payment_method"
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入支付方式!' },
      ];
    },
  },
  {
    label: '支付订单号',
    field: 'paymentReference',
    component: 'Input',
  },
  {
    label: '备注信息',
    field: 'note',
    component: 'Input',
  },
  {
    label: '支付时间',
    field: 'paymentTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '实付金额',
    field: 'paidAmount',
    component: 'InputNumber',
  },
  {
    label: '商品ID',
    field: 'productId',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  userId: { title: '用户', order: 0, view: 'sel_search', type: 'string', dictTable: "cu_user_details", dictCode: 'id', dictText: 'user_name', },
  orderId: { title: '订单号', order: 1, view: 'text', type: 'string', },
  paymentStatus: { title: '支付状态', order: 2, view: 'list', type: 'string', dictCode: 'payment_status', },
  paymentAmount: { title: '支付金额', order: 3, view: 'number', type: 'number', },
  refundTime: { title: '退款时间', order: 4, view: 'datetime', type: 'string', },
  paymentMethod: { title: '支付方式', order: 5, view: 'list', type: 'string', dictCode: 'payment_method', },
  paymentReference: { title: '支付订单号', order: 6, view: 'text', type: 'string', },
  note: { title: '备注信息', order: 7, view: 'text', type: 'string', },
  paymentTime: { title: '支付时间', order: 8, view: 'datetime', type: 'string', },
  paidAmount: { title: '实付金额', order: 9, view: 'number', type: 'number', },
  productId: { title: '商品ID', order: 10, view: 'text', type: 'string', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}